import 'package:flutter/material.dart';
import 'package:flutter_axrjc/page/main/check_manage/check_log/view.dart';
import 'package:flutter_axrjc/page/main/check_manage/my_light/view.dart';
import 'package:flutter_axrjc/widget/CachePage.dart';
import 'package:get/get.dart';

import 'logic.dart';

class CheckManagePage extends StatelessWidget {
  const CheckManagePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<CheckManageLogic>();
    return CachePage(
        child: Column(
      children: [
        Container(
          color: Colors.white,
          child: Column(
            children: [
              SafeArea(
                child: TabBar(
                  onTap: (i) {
                    logic.pageController.animateToPage(i,
                        duration: const Duration(milliseconds: 200),
                        curve: Curves.linear);
                  },
                  controller: logic.tabController,
                  indicatorSize: TabBarIndicatorSize.label,
                  padding: EdgeInsets.zero,
                  indicatorPadding:
                      const EdgeInsets.symmetric(horizontal: 30, vertical: 5),
                  indicatorWeight: 2,
                  indicatorColor: Colors.black,
                  labelColor: Colors.black,
                  labelStyle: const TextStyle(fontWeight: FontWeight.bold),
                  unselectedLabelStyle: const TextStyle(),
                  unselectedLabelColor: const Color(0xff999999),
                  labelPadding: EdgeInsets.zero,
                  tabs: const [
                    Padding(
                      padding: EdgeInsets.all(15),
                      child: Text("我的灯具"),
                    ),
                    Padding(
                      padding: EdgeInsets.all(15),
                      child: Text("检测记录"),
                    ),
                  ],
                  // controller: tabController,
                ),
              ),
            ],
          ),
        ),
        Expanded(
          child: PageView(
            onPageChanged: (i) {
              logic.tabController.animateTo(i);
            },
            controller: logic.pageController,
            children: const [
              MyLightPage(),
              CheckLogPage(),
            ],
          ),
        )
      ],
    ));
  }
}
